// login 方法参数
let options = {
    token: localStorage.getItem('rtmToken'),
    uid: JSON.parse(localStorage.getItem('user'))?.user_id
}



async function loginRTM() {

    // 你的 app ID
    const appID = "69ee1d0f77224d1897d21a1d3bc56cd4"

    // 初始化客户端
    const client = AgoraRTM.createInstance(appID)

    //创建频道
    let channel = client.createChannel("demoChannel")

    // 显示连接状态变化
    client.on('ConnectionStateChanged', function (state, reason) {
        console.log("State changed To: " + state + " Reason: " + reason)
    })


    // 登录 RTM 系统
    await client.login(options)


    return {
        client
    }
}

export default loginRTM